home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Gamer Resource Kit / Hardcore Gamer Resource Kit - Disc 2.iso / Utils / UNIX / UNZIP520 / WINGUI / WIZUNZIP.H < prev    next >
C/C++ Source or Header  |  1996-04-29  |  15KB  |  449 lines

  1. #ifndef __wizunzip_h   /* prevent multiple inclusions */
  2. #define __wizunzip_h
  3.  
  4. #include <windows.h>
  5. #include <assert.h>    /* required for all Windows applications */
  6. #include <commdlg.h>
  7. #include <dlgs.h>
  8.  
  9. /* Main include file for  Windows Unzip: wizunzip.h
  10.  * This include file is copied into all `C' source modules specific to 
  11.  * Windows Info-ZIP Unzip, version 3.0.
  12.  * Author: Robert A. Heath, 157 Chartwell Rd., Columbia, SC 29210
  13.  * I, Robert A. Heath, place this module, wizunzip.h, in the public domain.
  14.  *
  15.  * Modifications: 1995 M. White
  16.  */
  17.  
  18. /* Allow compilation under Borland C++ also */
  19. #ifndef __based
  20. #define __based(A)
  21. #endif
  22.  
  23. /* Porting definations between Win 3.1x and Win32 */
  24. #ifdef WIN32
  25. #  define far
  26. #  define _far
  27. #  define __far
  28. #  define near
  29. #  define _near
  30. #  define __near
  31. #endif
  32.  
  33. /*
  34.  * MW:
  35.  * The following is to take care of some of the porting problems between
  36.  * Win 3.1 and Win32 for WM_COMMAND notifications.
  37. */
  38. #ifdef WIN32
  39. #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
  40. #else
  41. #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(lp)
  42. #endif
  43.  
  44. #define WIZUNZIP_MAX_PATH       128   /* max total file or directory name path   */
  45. #define OPTIONS_BUFFER_LEN      256   /* buffer to hold .INI file options         */
  46.  
  47. /* These two are dependent on zip directory listing format string.
  48.  * They help find the filename in the listbox entry.
  49.  */
  50. #define SHORT_FORM_FNAME_INX     27
  51. #define LONG_FORM_FNAME_INX      58
  52.  
  53. #define MIN_SHORT_FORMAT_CHARS (SHORT_FORM_FNAME_INX+12)
  54. #define MIN_LONG_FORMAT_CHARS (LONG_FORM_FNAME_INX+12)
  55.  
  56. /* Arbitrary Constants
  57.  */
  58. #define BG_SYS_COLOR COLOR_GRAYTEXT /* background color is a system color */
  59.  
  60. /* Main window menu item positions
  61.  */
  62. #define EDIT_MENUITEM_POS         1   /* edit menu position in main menu */
  63. #define HELP_MENUITEM_POS         5   /* the Help menu                */
  64.  
  65. /* Main Window Message Codes
  66.  */
  67.  
  68. #define IDM_OPEN                101
  69. #define IDM_EXIT                102
  70.  
  71. #define IDM_SHORT               104
  72. #define IDM_LONG                105
  73.  
  74.  
  75. #define IDM_HELP                106
  76. #define IDM_ABOUT               107
  77.  
  78. #define IDM_RECR_DIR_STRUCT     108
  79. #define IDM_OVERWRITE           109
  80. #define IDM_SAVE_UNZIP_FROM_DIR 110
  81. #define IDM_SAVE_UNZIP_TO_DIR   111
  82. #define IDM_EXTRACT_ONLY_NEWER  112
  83. #define IDM_TRANSLATE           114
  84. #define IDM_SPACE_TO_UNDERSCORE 115
  85. #define IDM_UNZIP_TO_ZIP_DIR    116
  86.  
  87. #define IDM_LB_EXTRACT          117
  88. #define IDM_LB_DISPLAY          118
  89. #define IDM_LB_TEST             119
  90.  
  91.  
  92. #define IDM_EDIT                120
  93. #define IDM_PATH                121
  94.  
  95. #define IDM_UNZIP_FROM_DIR      122
  96.  
  97. #define IDM_COMMENT             123
  98. #define IDM_SOUND_OPTIONS       124
  99. #define IDM_COPY                125
  100. #define IDM_SELECT_ALL          126
  101.  
  102. /* These six items are the tab-stop windows whose ID's must be kept
  103.  * in order.
  104.  */
  105. #define IDM_LISTBOX             127
  106. #define IDM_EXTRACT             128
  107. #define IDM_DISPLAY             129
  108. #define IDM_TEST                130
  109. #define IDM_SHOW_COMMENT        131
  110. #define IDM_STATUS              132
  111.  
  112. #define TABSTOP_ID_BASE IDM_LISTBOX
  113.  
  114.  
  115. #define IDM_AUTOCLEAR_STATUS    133
  116. #define IDM_SELECT_BY_PATTERN   134
  117.  
  118. /* Keep these 3 in order */
  119. #define IDM_SPLIT               135
  120. #define IDM_MAX_LISTBOX         136
  121. #define IDM_MAX_STATUS          137
  122.  
  123. #define IDM_AUTOCLEAR_DISPLAY   138
  124.  
  125. /* Keep these 3 in order */
  126.  
  127. #define IDM_DESELECT_ALL        139
  128. #define IDM_CLEAR_STATUS        140
  129. #define IDM_HELP_KEYBOARD       141
  130. #define IDM_HELP_HELP           142
  131. #define IDM_CHDIR               143
  132. #define IDM_SETFOCUS_ON_STATUS  144 /* internal: posted after extraction to Status window */
  133.  
  134.  
  135. /* For the Copy, Move, Delete and Rename File functions */
  136. #define IDM_COPY_ARCHIVE        145
  137. #define IDM_MOVE_ARCHIVE        146
  138. #define IDM_DELETE_ARCHIVE      147
  139. #define IDM_RENAME_ARCHIVE      150
  140.  
  141. #define IDM_SAVE_AS_DEFAULT     161
  142.  
  143. #define IDM_MAKE_DIR            162
  144. #define IDM_MAKEDIR_PATH        163
  145. #define IDM_MAKEDIR_HELP        164
  146. #define IDM_CURRENT_PATH        165
  147. #define IDM_SHOW_BUBBLE_HELP    166
  148. #define IDM_PROMPT_TO_OVERWRITE 167
  149.  
  150. /* Help Window Menu and Message ID's
  151.  */
  152. #define INDEX_MENU_ITEM_POS       0
  153.  
  154. #define IDM_FORWARD             100
  155. #define IDM_BACKWARD            101
  156.  
  157. /*
  158.  * About box identifiers used to display the current version number
  159.  * information.
  160.  */
  161. #define IDM_ABOUT_VERSION_INFO  170
  162. #define IDM_ABOUT_UNZIP_INFO    171
  163.  
  164. #define BTNWIDTH        3.0
  165. #define MIN_BTN_WIDTH   1.5
  166.  
  167. extern int Width, Height;
  168. extern int BtnSeparator;
  169. extern float BtnMult;
  170.  
  171. #define NumOfBtns 21
  172.  
  173. /* Tab-stop table is used to sub-class those main window items to
  174.  * which the tab and back-tab keys will tab and stop.
  175.  */
  176. typedef struct TabStop_tag {
  177. FARPROC lpfnOldFunc;        /* original function                */
  178. HWND hWnd ;
  179. } TabStopEntry;
  180.  
  181. typedef TabStopEntry *PTABSTOPENTRY;
  182. #define TABSTOP_TABLE_ENTRIES 26
  183.  
  184.  
  185. #ifndef NDEBUG
  186. #define WinAssert(exp) \
  187.         {\
  188.         if (!(exp))\
  189.             {\
  190.             char szBuffer[40];\
  191.             sprintf(szBuffer, "File %s, Line %d",\
  192.                     __FILE__, __LINE__) ;\
  193.             if (IDABORT == MessageBox((HWND)NULL, szBuffer,\
  194.                 "Assertion Error",\
  195.                 MB_ABORTRETRYIGNORE|MB_ICONSTOP))\
  196.                     FatalExit(-1);\
  197.             }\
  198.         }
  199.  
  200. #else
  201.  
  202. #define WinAssert(exp)
  203.  
  204. #endif
  205.  
  206.  
  207. /* Unzip Flags */
  208. typedef struct
  209. {
  210. unsigned int   fRecreateDirs : 1;
  211. unsigned int   fShowBubbleHelp : 1;
  212. unsigned int   fTranslate : 1;
  213. unsigned int   fSaveUnZipToDir : 1;
  214. unsigned int   fSaveUnZipFromDir : 1;
  215. unsigned int   fFormatLong : 1;
  216. unsigned int   fUnzipToZipDir : 1;
  217. unsigned int   fBeepOnFinish : 1;
  218. unsigned int   fDoAll : 1;
  219. unsigned int   fIconSwitched : 1;
  220. unsigned int   fHelp : 1;
  221. unsigned int   fCanDragDrop : 1;
  222. unsigned int   fAutoClearStatus : 1;
  223. unsigned int   fAutoClearDisplay : 1;
  224. unsigned int   fTrailingSlash : 1;
  225. unsigned int   fPromptToOverwrite : 1;
  226. unsigned int   fUnused : 5;
  227. } UF, *PUF;
  228.  
  229. /* Unzip Miscellaneous Buffers */
  230. typedef struct
  231. {
  232. char szFileName[WIZUNZIP_MAX_PATH]; /* fully-qualified archive file name in OEM char set */
  233. char szDirName[WIZUNZIP_MAX_PATH];  /* directory of archive file in ANSI char set */
  234. char szUnzipToDirName[WIZUNZIP_MAX_PATH];    /* extraction ("unzip to") directory name in ANSI */
  235. char szUnzipToDirNameTmp[WIZUNZIP_MAX_PATH]; /* temp extraction ("unzip to") directory name in ANSI */
  236. char szUnzipFromDirName[WIZUNZIP_MAX_PATH];  /* extraction ("unzip from") directory name in ANSI */
  237. char szTotalsLine[80];              /* text for totals of zip archive */
  238. char szBuffer[OPTIONS_BUFFER_LEN];  /* option strings from .INI, & gen'l scratch buf */
  239. char szSoundName[WIZUNZIP_MAX_PATH];/* wave file name or sound from WIN.INI [sounds] in ANSI */
  240. char szPassword[81];
  241. LPSTR lpPassword;
  242. OPENFILENAME ofn;
  243. OPENFILENAME wofn;                  /* wave open file name struct */
  244. MSG msg;
  245. OFSTRUCT of;                        /* archive open file struct */
  246. OFSTRUCT wof;                       /* wave open file struct   */
  247. } UMB, __far *LPUMB;
  248.  
  249. #if defined (USEWIZUNZDLL) || defined (WIZUNZIPDLL)
  250. typedef int (far *DLLPRNT) (FILE *, unsigned int, char *);
  251. typedef void (far *DLLSND) (void);
  252.  
  253. typedef struct {
  254. DLLPRNT print;
  255. DLLSND sound;
  256. FILE *Stdout;
  257. LPUMB lpUMB;
  258. HWND hWndList;
  259. HWND hWndMain;
  260. HWND hInst;
  261. #else
  262. typedef struct {
  263. #endif
  264. int ExtractOnlyNewer;
  265. int Overwrite;
  266. int SpaceToUnderscore;
  267. int PromptToOverwrite;
  268. int ncflag;
  269. int ntflag;
  270. int nvflag;
  271. int nUflag;
  272. int nzflag;
  273. int ndflag;
  274. int noflag;
  275. int naflag;
  276. int argc;
  277. LPSTR lpszZipFN;
  278. char **FNV;
  279. } DCL, _far *LPDCL;
  280.  
  281. extern TabStopEntry TabStopTable[]; /* tab-stop control table           */
  282.  
  283. #ifndef WIN32
  284. extern short dxChar, dyChar;    /* size of char in SYSTEM font in pixels    */
  285. #else
  286. extern long dxChar, dyChar;    /* size of char in SYSTEM font in pixels    */
  287. #endif
  288.  
  289. extern HANDLE hFixedFont;
  290.  
  291. extern HWND hWndComment;        /* comment window                       */
  292. extern HWND hWndList;       /* listbox handle                       */
  293. extern HWND hWndButtonBar; /* Button bar handle */
  294.  
  295. extern HWND hWndMain;        /* the main window handle.         */
  296.  
  297. extern HWND hExtract;           /* extract button               */
  298. extern HWND hDisplay;           /*display button                */
  299. extern HWND hTest;              /* test button                  */
  300. extern HWND hShowComment;       /* show comment button          */
  301.  
  302. extern HWND hExit;
  303. extern HWND hMakeDir;
  304. extern HWND hSelectAll;
  305. extern HWND hDeselectAll;
  306. extern HWND hSelectPattern;
  307. extern HWND hClearStatus;
  308. extern HWND hCopyStatus;
  309. extern HWND hUnzipToDir;
  310.  
  311. extern HWND hHelp;
  312. extern HWND hOpen;
  313. extern HWND hCopyArchive;
  314. extern HWND hMoveArchive;
  315. extern HWND hRenameArchive;
  316. extern HWND hDeleteArchive;
  317. extern HWND hSplitButton;
  318. extern HWND hStatusButton;
  319. extern HWND hListBoxButton;
  320.  
  321. extern HWND hPatternSelectDlg; /* pattern select modeless dialog   */
  322. extern HANDLE hInst;                       /* current instance */
  323. extern HMENU  hMenu;                /* main menu handle         */
  324. extern HANDLE hAccTable;
  325.  
  326. extern HANDLE hHourGlass;             /* handle to hourglass cursor      */
  327. extern HANDLE hSaveCursor;            /* current cursor handle       */
  328. extern HANDLE hHelpCursor;          /* help cursor              */
  329. extern HANDLE hFixedFont;           /* handle to fixed font             */
  330. extern HANDLE hOldFont;         /* handle to old font               */
  331.  
  332. extern int hFile;                 /* file handle             */
  333. extern HWND hWndList;             /* list box handle        */
  334. extern HWND hWndStatus;     /* status   */
  335. extern BOOL bRealTimeMsgUpdate; /* update messages window in real-time */
  336. extern BOOL gfCancelDisplay;   /* cancel ongoing display operation */
  337. extern UF uf;
  338.  
  339. extern char szTargetDirName[];
  340. extern LPSTR lpchLast;
  341.  
  342. extern WPARAM wLBSelection;   /* default listbox selection action */
  343. extern WPARAM wWindowSelection; /* window selection: listbox, status, both   */
  344.  
  345. extern HBRUSH hBrush ;          /* brush for  standard window backgrounds  */
  346.  
  347. extern char __based(__segname("STRINGS_TEXT")) szCantChDir[];
  348. extern char __based(__segname("STRINGS_TEXT")) szCantCopyFile[];
  349. extern char __based(__segname("STRINGS_TEXT")) szAppName[];     /* application name             */
  350. extern char __based(__segname("STRINGS_TEXT")) szDefaultUnzipToDir[]; /* default unzip to dir */
  351. extern char __based(__segname("STRINGS_TEXT")) szDefaultUnzipFromDir[]; /* default unzip from dir */
  352. extern char __based(__segname("STRINGS_TEXT")) szStatusClass[]; /* status class name                */
  353. extern char __based(__segname("STRINGS_TEXT")) szFormatKey[];       /* Format .INI keyword       */
  354. extern char __based(__segname("STRINGS_TEXT")) szOverwriteKey[];    /* Overwrite .INI keyword        */
  355. extern char __based(__segname("STRINGS_TEXT")) szPromptOverwriteKey[];    /* Prompt to Overwrite .INI keyword        */
  356. extern char __based(__segname("STRINGS_TEXT")) szExtractOnlyNewerKey[];    /* Extract only newer .INI keyword        */
  357. extern char __based(__segname("STRINGS_TEXT")) szSaveUnZipToKey[]; /* SaveZipToDir keyword in WIN.INI     */
  358. extern char __based(__segname("STRINGS_TEXT")) szSaveUnZipFromKey[]; /* SaveZipFromDir keyword in WIN.INI     */
  359. extern char __based(__segname("STRINGS_TEXT")) szTranslateKey[];    /* Translate .INI keyword        */
  360. extern char __based(__segname("STRINGS_TEXT")) szSpaceToUnderscoreKey[];    /* SpaceToUnderscore .INI keyword        */
  361. extern char __based(__segname("STRINGS_TEXT")) szLBSelectionKey[];  /* LBSelection keyword in .INI */
  362. extern char __based(__segname("STRINGS_TEXT")) szRecreateDirsKey[]; /* re-create directory structure .INI keyword */
  363. extern char __based(__segname("STRINGS_TEXT")) szShowBubbleHelpKey[]; /* Show bubble help .INI keyword */
  364. extern char __based(__segname("STRINGS_TEXT")) szUnzipToZipDirKey[];   /* unzip to .ZIP dir .INI keyword */
  365. extern char __based(__segname("STRINGS_TEXT")) szAutoClearStatusKey[];   /* autoclear status .INI keyword */
  366. extern char __based(__segname("STRINGS_TEXT")) szAutoClearDisplayKey[];   /* autoclear status .INI keyword */
  367. extern char __based(__segname("STRINGS_TEXT")) szNoMemory[] ;       /* error message            */
  368. extern char __based(__segname("STRINGS_TEXT")) szHelpFileName[];        /* help file name                       */
  369. extern char __based(__segname("STRINGS_TEXT")) szWizUnzipIniFile[];   /* WizUnzip Private .INI file */
  370. extern char __based(__segname("STRINGS_TEXT")) szYes[];
  371. extern char __based(__segname("STRINGS_TEXT")) szNo[];
  372.  
  373. extern char * LBSelectionTable[];
  374. extern char * Headers[][2] ;        /* headers to display           */
  375. extern DWORD dwCommDlgHelpId; /* what to pass to WinHelp() */
  376.  
  377. extern WORD cchComment; /* length of comment in .ZIP file   */
  378. extern LPUMB lpumb;
  379. extern LPDCL lpDCL;
  380.  
  381. /* List box stuff
  382.  */
  383. extern WORD cZippedFiles;       /* total personal records in file   */
  384. extern WORD cListBoxLines; /* max list box lines showing on screen */
  385. extern WORD cLinesMessageWin; /* max visible lines on message window  */
  386.  
  387. /* Function Prototypes */
  388.  
  389. void SetCaption(HWND hWnd);
  390.  
  391. /* some global functions */
  392. void Action(HWND hWnd, WPARAM wActionCode);
  393. void CenterDialog(HWND hwndParent, HWND hwndDlg);
  394. void CopyStatusToClipboard(HWND hWnd);
  395. void DisplayComment(HWND hWnd);
  396. int CLBItemsGet(HWND hListBox, int __far * __far *ppnSelItems, HANDLE *phnd);
  397. void ReselectLB(HWND hListBox, int nSelCount, int __far *pnSelItems);
  398. #ifndef USEWIZUNZDLL
  399. BOOL FSetUpToProcessZipFile(LPDCL C);
  400. void TakeDownFromProcessZipFile(void);
  401. #endif
  402. void InitSoundOptions(void); /* initialize sound options (sound.c)   */
  403. void MigrateSoundOptions(void); /* translate beep into new option (sound.c) */
  404. void SetStatusTopWndPos(void);
  405. void SizeWindow(HWND hWnd, BOOL bOKtoMovehWnd);
  406. void SoundAfter(void);
  407. void SoundDuring(void);
  408. BOOL StatusInWindow(void);
  409. void UpdateButtons(HWND hWnd);
  410. void UpdateListBox(HWND hWnd);
  411. void UpdateMsgWndPos(void);
  412. BOOL WizUnzipInit(HANDLE hInst);
  413. void WriteBufferToMsgWin(LPSTR buffer, int nBufferLen, BOOL bUpdate);
  414. void WriteStringToMsgWin(PSTR String, BOOL bUpdate);
  415. int win_fprintf(FILE *file, unsigned int, char *);
  416. void CopyArchive(HWND hWnd, BOOL move_flag, BOOL rename_flag);
  417. void GetDirectory(LPSTR lpDir);
  418. BOOL MakeDirectory(char *path, BOOL fileAttached);
  419. LPSTR lstrrchr(LPSTR lpszSrc, char chFind);
  420. void MoveButtons(void);
  421. void CreateButtonBar(HWND);
  422.  
  423. /* Far Proc's */
  424. #ifdef WIZUNZIPDLL
  425. extern WINAPI DllProcessZipFiles(DCL far *);
  426. extern WINAPI GetDllVersion(DWORD far *);
  427. #endif
  428.  
  429. #ifdef USEWIZUNZDLL
  430. extern FARPROC DllProcessZipFiles;
  431. extern FARPROC GetDllVersion;
  432. #else
  433. BOOL WINAPI PasswordProc(HWND, WORD, WPARAM, LPARAM);
  434. #endif
  435. BOOL WINAPI AboutProc(HWND, WORD, WPARAM, LPARAM);
  436. BOOL WINAPI SelectDirProc(HWND, WORD, WPARAM, LPARAM);
  437. BOOL WINAPI CopyFileProc(HWND, WORD, WPARAM, LPARAM);
  438. long WINAPI KbdProc(HWND, WORD, WPARAM, LPARAM);
  439. BOOL WINAPI PatternSelectProc(HWND, WORD, WPARAM, LPARAM);
  440. BOOL WINAPI ReplaceProc(HWND, WORD, WPARAM, LPARAM);
  441. BOOL WINAPI SoundProc(HWND, WORD, WPARAM, LPARAM);
  442. long WINAPI StatusProc (HWND, WORD, WPARAM, LPARAM);
  443. BOOL WINAPI RenameProc (HWND, WORD, WPARAM, LPARAM);
  444. BOOL WINAPI MakeDirProc(HWND, WORD, WPARAM, LPARAM);
  445. LONG WINAPI ButtonBarWndProc(HWND, UINT, WPARAM, LPARAM);
  446. int GetReplaceDlgRetVal(void);
  447. #endif /* __wizunzip_h */
  448.  
  449.